/**
 * Created by Janpoem on 2016/1/31 0031.
 */

var fs = require('fs');

module.exports = {
	substitute: function(str, args) {
		var regex = /\{([^\{\}\r\n]+)\}/g;
		str = str.replace(regex, function(match, name) {
			if (args[name])
				return args[name];
			return '';
		});
		if (regex.test(str))
			return this.substitute(str, args);
		return str;
	},
	isDir: function(path) {
		try {
			return fs.lstatSync(path).isDirectory();
		}
		catch (err) {
			return false;
		}
		return false;
	}
};